<template>
	<view class="mine_wrap">
		<view class="head_wrap">
			<view :style="'height:' + statusBarHeight + 'px'"></view>
			<view class="title" :style="'height:' + navigatorBarHeight + 'px'">个人中心</view>
			<image class="mine_top" :src="remoteUrl + 'mine_top.png'" mode=""></image>
			<image class="mine_icon" :src="remoteUrl + 'mine_icon.png'" mode=""></image>
		</view>
		<view class="info_item">
			<view class="flex-row justify-between items-center relative no_login" v-if="is_login === 0">
				<text class="font text_2">您还未登录，请登录</text>
				<view class="flex-col items-center button text-wrapper" @click="toLogin()">
					<text class="font_2 text_3">登录</text>
				</view>
			</view>
			<view class="flex-col section_5" v-if="is_login === 1">
				<view class="flex-row justify-between relative group_3">
					<view class="flex-row">
						<image class="image_8" :src="ossUrl + detail.avatar" />
						<text class="self-start font text_2">{{ detail.nickname || '微信用户' }}</text>
						<view class="flex-col justify-start items-center shrink-0 self-start text-wrapper_2">
							<text class="font_3">{{ detail.gender == 0 ? '女' : detail.gender == 1 ? '男' : '' }}</text>
						</view>
					</view>
					<view class="flex-col justify-start items-center button text-wrapper" @click="toEdit()"><text class="font_2">编辑</text>
					</view>
				</view>
				<block v-if="config == 1">
					<view class="mt-14 flex-ali" style="width: 50%;" v-if="detail.company_position">
						<text class="font_4">{{ detail.company_position }}</text>
						<view class="view_2 view"></view>
						<text class="font_4 text_6">{{ detail.company_name }}</text>
						<view class="view_2 view_2"></view>
						<text class="font_4 text_7">{{ detail.company_industries }}</text>
					</view>
					<view class="mt-14 flex-ali" v-if="detail.school_name">
						<text class="font_4">{{ detail.school_name }}</text>
						<view class="view_2 ml-8"></view>
						<text class="font_4 ml-8">{{ detail.school_education }}</text>
						<view class="view_2 ml-8"></view>
						<text class="font_4 ml-8">{{ detail.school_major }}</text>
					</view>
					<view class="mt-14 flex" v-if="detail.intro">
						<text class="font_5">个人介绍：</text>
						<text class="font_6 row_1">{{ detail.intro }}</text>
					</view>
					<view class="mt-14 flex" v-if="detail.merit">
						<text class="font_5">优势资源：</text>
						<text class="font_6 row_1">{{ detail.merit }}</text>
					</view>
				</block>
				<!-- <view class="mt-14 flex-row">
					<view class="flex-col justify-start text-wrapper_3">
						<text class="font_3 text_11">热情开朗</text>
					</view>
					<view class="flex-col justify-start text-wrapper_3 ml-6">
						<text class="font_3 text_11">独立自信</text>
					</view>
					<view class="flex-col justify-start text-wrapper_3 ml-6">
						<text class="font_3 text_11">不惧挑战</text>
					</view>
				</view> -->
			</view>
		</view>

		<view class="flex-col section_6">
			<view class="flex-row justify-between items-center group_7">
				<text class="font text_4">供需发布</text>
				<view class="flex-row" @click="toList(0)">
					<text class="font_2 text_5">全部</text>
					<image class="shrink-0 image_8 ml-6" :src="remoteUrl + 'right_icon.png'" />
				</view>
			</view>
			<view class="flex-row mt-10">
				<view class="flex-col items-center group_8" @click="toList(1)">
					<text class="num" v-if="status_0 > 0">{{ status_0 }}</text>
					<image class="image_9" :src="remoteUrl + 'audit_icon.png'" />
					<text class="mt-6 font_3 text_5">待审核</text>
				</view>
				<view class="ml-6 flex-col items-center group_8" @click="toList(2)">
					<text class="num" v-if="status_1 > 0">{{ status_1 }}</text>
					<image class="image_9" :src="remoteUrl + 'published_icon.png'" />
					<text class="mt-6 font_3 text_5">已发布</text>
				</view>
				<view class="ml-6 flex-col items-center group_8" @click="toList(3)">
					<text class="num" v-if="status_2 > 0">{{ status_2 }}</text>
					<image class="image_9" :src="remoteUrl + 'no_pass_icon.png'" />
					<text class="mt-6 font_3 text_5">未通过</text>
				</view>
			</view>
		</view>

		<!-- 服务商信息 -->
		<view class="mt-10 flex-col section_8">
			<view class="flex-row justify-between items-center self-stretch" @click="toCompany()">
				<text class="font">服务商信息</text>
				<view class="flex-ali">
					<text class="font_7 text_16">信息维护</text>
					<image class="ml-6 image_9" :src="remoteUrl + 'right_icon.png'" />
				</view>
			</view>
			<text class="self-start text_11 text_20" v-if="detail.company">{{ detail.company.name }}</text>
			<view class="flex-col self-stretch group_9" v-if="detail.company">
				<text class="self-stretch font_9 text_16 row_3">
					{{ detail.company.introduce }}
				</text>
			</view>
		</view>

		<view class="mt-10 flex-col list">
			<view class="flex-row justify-between list-item" @click="toCollect()" v-if="config == 1">
				<text class="font_10">我的收藏</text>
				<image class="image_11" :src="remoteUrl + 'right_icon.png'" />
			</view>
			<view class="flex-row justify-between list-item" @click="toBuy()" v-if="config == 1">
				<text class="font_10">我的购买</text>
				<image class="image_11" :src="remoteUrl + 'right_icon.png'" />
			</view>
			<view class="flex-row justify-between list-item" @click="toPublish()">
				<text class="font_10">我的报名</text>
				<image class="image_11" :src="remoteUrl + 'right_icon.png'" />
			</view>
			<view class="flex-row justify-between list-item" @click="toFeed()">
				<text class="font_10">意见反馈</text>
				<image class="image_11" :src="remoteUrl + 'right_icon.png'" />
			</view>
		</view>
		
		<CustomTabBar :selected="4"></CustomTabBar>
	</view>
</template>

<script>
	import {
		remoteUrl,
		ossUrl
	} from '@/utils/config.js'
	import { 
		getUserInfo,
	} from '@/api/mine.js'
	import {
		auditCount
	} from '@/api/home.js'
	import CustomTabBar from "@/components/CustomTabBar/CustomTabBar.vue"
	const app = getApp()
	export default {
		components: {
			CustomTabBar
		},
		data() {
			return {
				statusBarHeight: app.globalData.navigator.statusBarHeight,
				navigatorBarHeight: app.globalData.navigator.navigatorBarHeight,
				remoteUrl: remoteUrl,
				ossUrl: ossUrl,
				is_login: uni.getStorageSync('userInfo') ? 1 : 0, // 0 未登录  1 已登录
				detail: '',
				status_0: 0,
				status_1: 0,
				status_2: 0,
				config: 0,
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.config = uni.getStorageSync('config') || 0
			this.is_login = uni.getStorageSync('userInfo') ? 1 : 0
			if (this.is_login == 1) {
				this.getUserInfoFun()
				this.auditCountFun()
			} 
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: '小程序分享',
				imageUrl: '',
			}
		},
		methods: {
			auditCountFun() {
				auditCount().then(res => {
					if (res.code == 1) {
						this.status_0 = res.data[0].count
						this.status_1 = res.data[1].count
						this.status_2 = res.data[2].count
					}
				})
			},
			getUserInfoFun() {
				getUserInfo().then(res => {
					if (res.code == 1) {
						this.detail = res.data
					}
				})
			},
			// 跳转编辑个人信息
			toEdit() {
				if (this.detail.company_name != '' && this.detail.company_name != null) {
					uni.navigateTo({
						url: '/pages/pages-list/up_info/up_info?detail=' + encodeURIComponent(JSON.stringify(this.detail))
					})
				}else {
					uni.navigateTo({
						url: '/pages/pages-list/up_info/up_info'
					})
				}
				
			},
			// 跳转我的购买
			toBuy() {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '/pages/pages-list/my_buy/my_buy'
				})
			},
			// 跳转我的报名
			toPublish() {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '/pages/pages-list/my_publish/my_publish'
				})
			},
			// 跳转我的收藏
			toCollect() {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '/pages/pages-list/my_collect/my_collect'
				})
			},
			// 跳转添加服务商信息
			toCompany() {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				if (this.detail.company != null) {
					uni.navigateTo({
						url: '/pages/pages-list/up_service/up_service?detail=' + encodeURIComponent(JSON.stringify(this.detail.company))
					})
				}else {
					uni.navigateTo({
						url: '/pages/pages-list/up_service/up_service'
					})
				}
			},
			// 跳转我的发布
			toList(index) {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '/pages/pages-list/publish_list/publish_list?index=' + index
				})
			},
			// 跳转反馈
			toFeed() {
				if (!uni.getStorageSync('userInfo')) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
				uni.navigateTo({
					url: '/pages/pages-list/feedback/feedback'
				})
			},
			toLogin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mine_wrap {
		min-height: 100vh;
		padding-bottom: 120rpx;
		background: #F6F8FF;

		.head_wrap {
			width: 100vw;
			height: 476rpx;
			background: linear-gradient(180deg, #1C41F1 0%, #1c41f100 100%);
			padding: 0 30rpx;
			position: relative;

			.title {
				display: flex;
				align-items: center;
				color: #fff;
				font-size: 36rpx;
				position: absolute;
				z-index: 1;
			}

			.mine_top {
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
			}
			.mine_icon {
				width: 303rpx;
				height: 309rpx;
				position: absolute;
				top: 0;
				right: 0;
				opacity: .5;
			}
		}

		.info_item {
			position: relative;
			z-index: 2;

			.no_login {
				width: 690rpx;
				margin: -200rpx auto 0;
				padding: 30rpx 32rpx;
				background-color: #ffffff33;
				border-radius: 24rpx;

				.font {
					font-size: 32rpx;
					color: #000000;
				}

				.text_2 {
					color: #ffffff;
				}

				.button {

					.font_2 {
						font-size: 26rpx;
						color: #000000;
					}

					.text_3 {
						color: #1c41f1;
					}
				}

				.text-wrapper {
					padding: 16rpx 0;
					background-color: #ffffff;
					border-radius: 54rpx;
					width: 180rpx;
				}
			}

			.section_5 {
				width: 690rpx;
				margin: -200rpx auto 0;
				padding: 0 22rpx 32rpx 30rpx;
				background: #ffffff;
				border-radius: 24rpx;

				.group_3 {
					margin-top: -60rpx;

					.image_8 {
						border-radius: 120rpx;
						width: 140rpx;
						height: 140rpx;
					}

					.font {
						font-size: 32rpx;
						color: #000000;
					}

					.text_2 {
						margin-left: 22rpx;
						margin-top: 98rpx;
					}

					.text-wrapper_2 {
						margin-left: 14rpx;
						margin-top: 103rpx;
						padding: 6rpx 8rpx;
						background-color: #1c41f133;
						border-radius: 4rpx;
					}

					.button {
						align-self: flex-start;
						margin-top: 92rpx;

						.font_2 {
							font-size: 24rpx;
							color: #1c41f1;
						}
					}

					.text-wrapper {
						padding: 6rpx 0;
						background-color: #ffffff;
						border-radius: 54rpx;
						width: 92rpx;
						border: solid 1rpx #1c41f1;
					}
				}

				.font_4 {
					max-width: 190rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					font-size: 26rpx;
					color: #1c41f1;
				}

				.view {
					background-color: #1c41f166;
					width: 2rpx;
					height: 24rpx;
					margin-left: 16rpx;
				}

				.text_6 {
					margin-left: 18rpx;
				}

				.view_2 {
					background-color: #1c41f166;
					width: 2rpx;
					height: 24rpx;
					margin-left: 14rpx;
				}

				.text_7 {
					margin-left: 20rpx;
				}

				.font_5 {
					font-size: 26rpx;
					color: #00000080;
				}

				.font_6 {
					width: 80%;
					font-size: 26rpx;
					color: #000000;
				}

				.text-wrapper_3 {
					padding: 6rpx 8rpx;
					background-color: #1c41f133;
					border-radius: 4rpx;

					.text_11 {
						opacity: 0.9;
					}
				}

				.font_3 {
					font-size: 22rpx;
					color: #1c41f1;
				}
			}
		}

		.section_6 {
			position: relative;
			z-index: 1;
			width: 690rpx;
			margin: 30rpx auto;
			padding: 30rpx 0 20rpx;
			background-color: #ffffff;
			border-radius: 24rpx;

			.group_7 {
				padding: 0 30rpx;

				.font {
					font-size: 32rpx;
					font-family: PingFang SC;
					line-height: 29.94rpx;
					color: #000000;
				}

				.text_4 {
					line-height: 30.02rpx;
				}

				.font_2 {
					font-size: 26rpx;
					font-family: PingFang SC;
					line-height: 23.94rpx;
					color: #000000;
				}

				.image_8 {
					opacity: 0.5;
					width: 12rpx;
					height: 24rpx;
				}
			}

			.group_8 {
				flex: 1 1 222rpx;
				padding: 12rpx 0;
				position: relative;

				.num {
					position: absolute;
					top: 10rpx;
					right: 60rpx;
					z-index: 2;
					width: 32rpx;
					height: 32rpx;
					text-align: center;
					color: #fff;
					background: #1C41F1;
					border-radius: 32rpx;
					font-size: 20rpx;
					border: 3rpx solid #FFFFFF;
				}

				.image_9 {
					width: 96rpx;
					height: 96rpx;
				}

				.font_3 {
					font-size: 24rpx;
					font-family: PingFang SC;
					line-height: 22.06rpx;
					color: #000000;
				}
			}

			.text_5 {
				opacity: 0.5;
			}
		}

		// 服务商信息
		.section_8 {
			width: 690rpx;
			margin: 0 auto;
			padding: 30rpx 32rpx 24rpx;
			background-color: #ffffff;
			border-radius: 24rpx;

			.font {
				font-size: 32rpx;
				color: #000000;
			}

			.font_7 {
				font-size: 26rpx;
			}

			.text_16 {
				opacity: 0.5;
			}

			.image_9 {
				opacity: 0.5;
				width: 12rpx;
				height: 24rpx;
			}

			.text_11 {
				opacity: 0.9;
			}

			.text_20 {
				margin-top: 24rpx;
				color: #000000;
				font-size: 30rpx;
			}

			.group_9 {
				margin-right: 4rpx;
				margin-top: 18rpx;

				.font_9 {
					font-size: 24rpx;
					color: #000000;
				}
			}
		}

		.list {
			width: 690rpx;
			margin: 30rpx auto;
			padding: 0 30rpx 4rpx;
			background-color: #ffffff;
			border-radius: 24rpx;

			.list-item {
				padding: 40rpx 0;
				align-items: center;
				border-bottom: solid 1rpx #d9d9d9;

				.font_10 {
					font-size: 28rpx;
					color: #000000;
				}

				.image_11 {
					width: 12rpx;
					height: 24rpx;
				}
			}
			.list-item:last-child {
				border-bottom: none;
			}
		}
	}
</style>